package eu.jpereira.trainings.designpatterns.creational.builder;

import eu.jpereira.trainings.designpatterns.creational.builder.model.ReportBody;
import eu.jpereira.trainings.designpatterns.creational.builder.xml.XMLReportBody;

public class XMLReportBuilder implements iReportBuilder {

	private XMLReportBody reportBody = new XMLReportBody();
	
	@Override
	public iReportBuilder setCustomerName(String name) {

		reportBody.putContent("<sale><customer><name>");
		reportBody.putContent(name);
		
		return null;
	}

	@Override
	public iReportBuilder setCustomerPhone(String phone) {

		reportBody.putContent("</name><phone>");
		reportBody.putContent(phone);
		reportBody.putContent("</phone></customer>");
		
		return null;
	}

	@Override
	public iReportBuilder makeItemList() {

		reportBody.putContent("<items>");
		
		return null;
	}

	@Override
	public iReportBuilder addItem(String name, int quantity, double price,
			boolean hasNext) {

		reportBody.putContent("<item><name>");
		reportBody.putContent(name);
		reportBody.putContent("</name><quantity>");
		reportBody.putContent(quantity);
		reportBody.putContent("</quantity><price>");
		reportBody.putContent(price);
		reportBody.putContent("</price></item>");
		
		if( !hasNext ){
				reportBody.putContent("</items></sale>");
		}
		
		return null;
	}

	@Override
	public ReportBody getReportBody() {
		return this.reportBody;
	}

}
